class TwoDArray extends Object;

var array<int> myMatrix; //declare a variable of type dynamic array of integers
var int rows; //number of rows in the 2D array
var int cols; //number of cols in the 2D array

function setDimensions(int numrows, int numcols)
{
	rows = numrows;
	cols = numcols;
	myMatrix.Length = rows * cols;
}

final function set(int row, int col, int value)
{
	myMatrix[twoDToOneD(row, col)] = value;
}

final function int get(int row, int col)
{
	return myMatrix[twoDToOneD(row, col)];
}

final function int twoDToOneD(int row, int col)
{
	return col+(row*cols);
}

//sets all elements to 0, useful when changing the rotation of a piece
final function clear()
{
	local int index;
	for(index = 0; index < myMatrix.Length; index++)
	{
		myMatrix[index] = 0;
	}
}

function int getLength()
{
	return myMatrix.Length;
}

DefaultProperties
{
	rows = 1;
	cols = 1;
	myMatrix = (0); //set the length to 1 with a value of 0 as default
}